//
//  ZCOrderListBodySearchView.m
//  ZCJZ
//
//  Created by sujeking on 2019/4/4.
//  Copyright © 2019年 jeking. All rights reserved.
//

#import "ZCOrderListBodySearchView.h"
#import "TBCityIconFont.h"
#import "generalToolBox.h"
@interface ZCOrderListBodySearchView()<UITextFieldDelegate>

@property (nonatomic, strong) UITextField *inputTF;
@property (nonatomic, strong) UIImageView *searchIconImv;

@end


@implementation ZCOrderListBodySearchView

- (instancetype)initWithFlex:(NSString *)flexname Frame:(CGRect)frame Owner:(NSObject *)owner {
    self = [super initWithFlex:flexname Frame:frame Owner:owner];
    if (self) {
        [self setupSubViews];
    }
    return self;
}

- (void)setupSubViews {
    UIImage *img = [UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e617", 20, [generalToolBox getColorWithHexadecimalColorStr:@"0xC20114"])];
    img = [img imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    self.searchIconImv.image = img;
    self.inputTF.layer.cornerRadius = CGRectGetHeight(self.inputTF.bounds) / 2;
    self.inputTF.layer.masksToBounds = YES;
    self.inputTF.delegate = self;
    
    self.inputTF.leftViewMode = UITextFieldViewModeAlways;
}

- (void)searchBtnClickAction {
    if (self.endEditCallback) {
        self.endEditCallback(self.inputTF.text);
    }
}

// MARK: - UITextFieldDelegate

- (void)textFieldDidEndEditing:(UITextField *)textField {
    if (self.endEditCallback) {
        self.endEditCallback(textField.text);
    }
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    return YES;
}


- (void)setPlacehstr:(NSString *)placehstr {
    _placehstr = placehstr;
    self.inputTF.placeholder = placehstr;
}

@end
